package cn.chengpengper.seckill.mq.local;

import cn.chengpengper.seckill.common.model.message.TopicMessage;
import cn.chengpengper.seckill.mq.MessageSenderService;
import com.alibaba.cola.event.EventBusI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * @author chengpeng.hu
 */
@Component
@ConditionalOnProperty(name = "message.mq.type", havingValue = "cola")
public class LocalMessageSenderServiceImpl implements MessageSenderService {

    @Autowired
    private EventBusI eventBus;

    @Override
    public boolean send(TopicMessage message) {
        eventBus.fire(message);
        return true;
    }

}
